package com.dmall.sharding.jdbc.service.impl;

import com.dmall.sharding.jdbc.domain.User;
import com.dmall.sharding.jdbc.mapper.PromotionMapper;
import com.dmall.sharding.jdbc.mapper.UserMapper;
import com.dmall.sharding.jdbc.service.UserService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

@Service
public class UserServiceImpl implements UserService {

    @Resource
    private UserMapper userMapper;
    @Resource
    private PromotionMapper promotionMapper;

    @Override
    public User findById(Integer id) {
        return userMapper.selectById(id);
    }

    @Override
    public void save(User user) {
        userMapper.insertUser(user);
    }

    @Override
    public Object select(String sql) {
        return promotionMapper.executeSelect(sql);
    }

    @Override
    @Transactional
    public Object insert(String sql) {
        return promotionMapper.executeUpdate(sql);
    }
}
